package org.lt.ttkv;

import androidx.annotation.NonNull;

import org.lt.ttkv.store.DefaultKVTool;
import org.lt.ttkv.store.KVTool;

import java.util.HashMap;

/**
 * @ClassName: KVConfigs
 * @Description: 类作用描述
 * @Author: wtl
 * @CreateDate: 2023/7/5 19:34
 * @UpdateUser: 更新者 wtl
 * @UpdateDate: 2023/7/5 19:34
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class KVConfigs {
  private final static HashMap<String, KVTool> sKeyValueTools = new HashMap<>();
  protected static KVTool sKVToolImpl = new DefaultKVTool();

  public static KVTool getKeyValueTool(@NonNull String groupName) {
    KVTool KVTool = sKeyValueTools.get(groupName);
    if (KVTool == null) {
      KVTool = sKVToolImpl.getNewInstance();
      KVTool.init(groupName);
      sKeyValueTools.put(groupName, KVTool);
    }
    return KVTool;
  }

  public static void setKeyValueToolImpl(@NonNull KVTool KVTool) {
    sKVToolImpl = KVTool;
  }
}